<?php

require_once 'Zend/Auth/Result.php';

/**
 * @category Application
 * @package User
 * @license nuophp
 *
 */
class User_Plugin_Auth_Result extends Zend_Auth_Result
{
	/**
	 * General Failure
	 * @property int
	 */
	const FAILURE = 0;

	/**
	 * Failure due to identity not being found.
	 * @property int
	 */
	const FAILURE_IDENTITY_NOT_FOUND = -1;

	/**
	 * Failure due to identity being ambiguous.
	 * @property int
	 */
	const FAILURE_IDENTITY_AMBIGUOUS = -2;

	/**
	 * Failure due to invalid credential being supplied.
	 * @property int
	 */
	const FAILURE_CREDENTIAL_INVALID = -3;

	/**
	 * Failure due to uncategorized reasons.
	 * @property int
	 */
	const FAILURE_UNCATEGORIZED = -4;

	/**
	 * user in-active
	 * @property int
	 */
	const FAILURE_USER_INACTIVE = -5;

	/**
	 * user is blocked
	 * @property int
	 */
	const FAILURE_USER_BLOCKED = -6;

	/**
	 * user is banned
	 * @property int
	 */
	const FAILURE_USER_BANNED = -7;

	/**
	 * expired
	 * @property int
	 */
	const FAILURE_USER_EXPIRED = -8;

	/**
	 * expired
	 * @property int
	 */
	const FAILURE_USER_UNCONFIRM = -8;

	/**
	 * expired
	 * @property int
	 */
	const FAILURE_USER_UNAPPROVED = -8;

	/**
	 * Authentication success.
	 * @property int
	 */
	const SUCCESS = 1;

	/**
	 * Authentication result code
	 *
	 * @var int
	 */
	protected $_code;

	/**
	 * The identity used in the authentication attempt
	 *
	 * @var mixed
	 */
	protected $_identity;

	/**
	 * An array of string reasons why the authentication attempt was unsuccessful
	 *
	 * If authentication was successful, this should be an empty array.
	 *
	 * @var array
	 */
	protected $_messages;

	/**
	 * Sets the result code, identity, and failure messages
	 *
	 * @param  int     $code
	 * @param  mixed   $identity
	 * @param  array   $messages
	 * @return void
	 */
	public function __construct($code, $identity, array $messages = array())
	{
		$this -> _code = (int)$code;
		$this -> _identity = (int)$identity;
		$this -> _messages = $messages;
	}

	/**
	 * Returns whether the result represents a successful authentication attempt
	 *
	 * @return boolean
	 */
	public function isValid()
	{
		return $this -> _code === 1;
	}

	/**
	 * getCode() - Get the result code for this authentication attempt
	 *
	 * @return int
	 */
	public function getCode()
	{
		return $this -> _code;
	}

	/**
	 * Returns the identity used in the authentication attempt
	 *
	 * @return mixed
	 */
	public function getIdentity()
	{
		return $this -> _identity;
	}

	/**
	 * Returns an array of string reasons why the authentication attempt was
	 * unsuccessful
	 *
	 * If authentication was successful, this method returns an empty array.
	 *
	 * @return array
	 */
	public function getMessages()
	{
		return $this -> _messages;
	}

}
